#※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
# File Name: var.sh
# Author: GID5564
# Description:   应该将自己定义的变量与xlib需要的变量分开，并加以说明！自定义变量不允许出现在xlib中！
# Created Time: 21/11/23-20:33:25
#※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
#! /usr/bin/env bash

# 避免重复导入
#[[ -n $__XLIB_IMPORTED__VAR ]] && return 0
#__XLIB_IMPORTED__VAR=1

export BIN_VAR=${BASH_SOURCE[0]:-$0}
function __var_init__(){
    #
    local script_dir=$(cd "$(dirname "${BIN_VAR}")" &>/dev/null && pwd -P)
    export XSHELL_PATH="${script_dir%/*}"
    unset script_dir
    loadGlobalVariables
}

#设置全局变量
function loadGlobalVariables(){
    #当前shell
    export SHELL=${SHELL:-zsh}
    #PS1
    
    # 检查 PROMPT 是否为空或保持默认值
    if [[ -z "${PROMPT}" ]] || [[ "${PROMPT}" == "$ " ]]; then
        # 设置新提示符：洋红色时间 + 用户@主机:工作目录$
        PROMPT='【\[\e[38;5;196m\]$(date "+%Y-%m-%d %H:%M:%S")\[\e[0m\]】\[\e[38;5;082m\]\u@\h\[\e[0m\]:\[\e[38;5;226m\]\w\[\e[0m\]\$\n>> '
    fi

    # 保存原始提示符到环境变量（供子进程使用）
    export _OLD_PS="${PROMPT}"

    
    #♦初始化路径变量
    export SYS_ROOT=${HOME:-'/root'}
    export SYS_HOME=${SYS_HOME:-'/home'}
    export SYS_USER=${SYS_USER:-'/usr/local'}
    export SYS_SDCARD=${SYS_SDCARD:-'/sdcard'}
    #图片目录
    export IMAGES_PATH=${IMAGES_PATH:-"${SYS_HOME}/images"}
    #保存结果目录
    export SAVE_PATH=${SAVE_PATH:-"${SYS_HOME}/save"}
    #备份目录
    export BACKUP_PATH=${BACKUP_PATH:-"${SYS_HOME}/backup"}
    
    export FILE_VIM="${SYS_ROOT}/.vimrc"
    export FILE_BASH="${SYS_ROOT}/.bashrc"
    export FILE_ZSH="${SYS_ROOT}/.zshrc"
    #启动引导
    export FILE_RC="${SYS_ROOT}/.rc.local"
    #会话问候
    export FILE_MOTD="/data/data/com.aidlux/files/usr/etc/motd"
    #代码重用
    export FILE_SNIPPET="/usr/local/share/jupyter/nbextensions/snippets/snippets.json"
    export PATH_DIST_PACKAGES="/usr/local/lib/python3.7/dist-packages"
    
    #matplotlib配置文件
    export FILE_MATPLOT="${PATH_DIST_PACKAGES}/matplotlib/mpl-data/matplotlibrc"
    
    #仓库
    export GITEE='aHR0cHM6Ly9naXRlZS5jb20vZ2lkNTU2NA=='
    export MYGIT=$(base64 -d <<< ${GITEE})
    export BIND='127.0.0.1'
    export HTML_DOC=${SYS_USER}"/html_doc"
}




















__var_init__












